package org.duang.db.mongo.parser.encode;

import java.lang.reflect.Field;

import org.duang.db.annotation.Vo;
import org.duang.db.mongo.parser.EncodeConvetor;
import org.duang.kit.ToolsKit;

/**
 * Vo对象属性转换
 * @author laotang
 */
public class VoEncoder extends Encoder {

	public VoEncoder( Object value, Field field ) {
		super(value, field);
	}

	@Override
	public String getFieldName() {
		String fieldName = field.getAnnotation(Vo.class).name();
		return (ToolsKit.isNotEmpty(fieldName)) ? fieldName : field.getName();
	}

	@Override
	public Object getValue() {
		return EncodeConvetor.convetor(value);
	}

}
